package com.cy.server.pojo;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * @peoject: yeb
 *
 * @description: 公共返回对象
 *
 * @author: LiShaoZhuo
 *
 * @create: 2021-04-26 15:55
 **/
@Data
public class RespBean<T> {
    private long code;
    private String message;
    private T data;

    public RespBean() {

    }

    public RespBean(long code, String message, T data) {
        this.code = code;
        this.message = message;
        this.data = data;
    }

    public RespBean(long code, T data) {
        this.code = code;
        this.data = data;
    }

    public RespBean(T data) {
        this.data = data;
    }

    /**
    * @Description: 成功返回结果
    * @Param: message
    * @return:  
    * @Author: LiShaoZhuo 
    * @Date: 2021/4/26 
    */
    public static <T> RespBean<T> success(String message){
        return new RespBean(200,message,null);
    }

    /**
    * @Description: 成功返回结果
    * @Param: message,data
    * @return:
    * @Author: LiShaoZhuo
    * @Date: 2021/4/26
    */
    public static <T> RespBean<T> success(String message,T data){
        return new RespBean(200,message,data);
    }

    /**
     * @Description: 成功返回结果
     * @Param: data
     * @return:
     * @Author: LiShaoZhuo
     * @Date: 2021/4/26
     */
    public static <T> RespBean<T> success(T data){
        return new RespBean<>(200,data);
    }

    /**
    * @Description: 失败返回结果
    * @Param: message
    * @return:
    * @Author: LiShaoZhuo
    * @Date: 2021/4/26
    */
    public static <T> RespBean<T> error(String message){
        return new RespBean(500,message,null);
    }

    /**
    * @Description: 失败返回结果
    * @Param: message,data
    * @return:
    * @Author: LiShaoZhuo
    * @Date: 2021/4/26
    */
    public static <T> RespBean<T> error(String message,T data){
        return new RespBean(500,message,data);
    }

    /**
     * @Description: 失败返回结果
     * @Param: data
     * @return:
     * @Author: LiShaoZhuo
     * @Date: 2021/4/26
     */
    public static <T> RespBean<T> error(T data){
        return new RespBean<T>(500,data);
    }
}
